﻿using Coldairarrow.Business.Base_leasesystem_merchant_img;
using Coldairarrow.Entity.Base_leasesystem_merchant_img;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
using NSwag.Annotations;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers.Base_leasesystem_merchant_img
{
    /// <summary>
    /// 客户证件照片控制器
    /// </summary>
    [Route("/Base_leasesystem_merchant_img/[controller]/[action]")]
    [OpenApiTag("客户证件照片控制器")]
    public class leasesystem_merchant_imgController : BaseApiController
    {
        #region DI

        public leasesystem_merchant_imgController(Ileasesystem_merchant_imgBusiness leasesystem_merchant_imgBus)
        {
            _leasesystem_merchant_imgBus = leasesystem_merchant_imgBus;
        }

        Ileasesystem_merchant_imgBusiness _leasesystem_merchant_imgBus { get; }

        #endregion

        #region 获取

        [HttpPost]
        public async Task<PageResult<leasesystem_merchant_img>> GetDataList(PageInput<ConditionDTO> input)
        {
            return await _leasesystem_merchant_imgBus.GetDataListAsync(input);
        }

        [HttpPost]
        public async Task<leasesystem_merchant_img> GetTheData(IdInputDTO input)
        {
            return await _leasesystem_merchant_imgBus.GetTheDataAsync(input.id);
        }

        [HttpPost]
        public object GetListById(IdInputDTO input)
        {
            return _leasesystem_merchant_imgBus.GetListById(input.id);
        }

        #endregion

        #region 提交

        [HttpPost]
        public async Task SaveData(leasesystem_merchant_img data)
        {
            if (data.Id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _leasesystem_merchant_imgBus.AddDataAsync(data);
            }
            else
            {
                await _leasesystem_merchant_imgBus.UpdateDataAsync(data);
            }
        }

        [HttpPost]
        [ApiPermission("merchant_img.Delete")]
        public async Task DeleteData(List<string> ids)
        {
            await _leasesystem_merchant_imgBus.DeleteDataAsync(ids);
        }

        [HttpPost]
        public int Delete(IdInputDTO input)
        {
            return _leasesystem_merchant_imgBus.DeleteData(input.id);
        }


        #endregion
    }
}